package com.sbs.gaoxinqutoilet.adapter;


import android.view.View;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sbs.gaoxinqutoilet.R;
import com.sbs.gaoxinqutoilet.entity.CheckItemEntity;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by 聪明一只哈 on 2018/5/30.
 * Time: 2018/5/30  17:37
 */

public class ToiletCheckRvAdapter extends BaseQuickAdapter<CheckItemEntity.DataBean, ToiletCheckRvAdapter.BuyApplyViewHolder> {


    public ToiletCheckRvAdapter(@LayoutRes int layoutResId, @Nullable List<CheckItemEntity.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BuyApplyViewHolder helper, CheckItemEntity.DataBean item) {


        helper.setText(R.id.item_check_tv_name,item.getHuming());
       // helper.setText(R.id.item_tf_buildcheck,item.getGaizao_type_n());
        helper.setText(R.id.item_tf_buildcheck,item.getOpt_time_str());//这个原来是改造类型,要改为抽检时间
        helper.setText(R.id.item_tv_address_check,item.getArea_name());


        //市级待检查 这几个字的个数会影响布局
        switch(item.getJiancha_result_n()){
            case "未检查":
                if ("市级".equals(item.getJiancha_level())){
                    helper.getView(R.id.item_tf_image).setBackgroundResource(R.drawable.citydjc);
                    helper.setText(R.id.item_check_statedesc,"市级未检查");
                }else if ("县级".equals(item.getJiancha_level())){
                    helper.getView(R.id.item_tf_image).setBackgroundResource(R.drawable.contydjc);
                    helper.setText(R.id.item_check_statedesc,"县级未检查");
                }

                break;
            case "合格":
                if ("县级".equals(item.getJiancha_level())){
                    helper.getView(R.id.item_tf_image).setBackgroundResource(R.drawable.contytg);
                    helper.setText(R.id.item_check_statedesc,"县级合格");
                }else if ("市级".equals(item.getJiancha_level())){
                    helper.getView(R.id.item_tf_image).setBackgroundResource(R.drawable.contydjc);
                    helper.setText(R.id.item_check_statedesc,"市级合格");
                }

                break;
            case "不合格":
                if ("县级".equals(item.getJiancha_level())){
                    helper.getView(R.id.item_tf_image).setBackgroundResource(R.drawable.contywtg);
                    helper.setText(R.id.item_check_statedesc,"县级不合格");
                }else if ("市级".equals(item.getJiancha_level())){
                    helper.getView(R.id.item_tf_image).setBackgroundResource(R.drawable.contydjc);
                    helper.setText(R.id.item_check_statedesc,"市级不合格");
                }

                break;

            default:

                break;
        }

//----------adapter条目点击-----------------------------------
//        helper.addOnClickListener(R.id.buy_apply_ll).addOnClickListener(R.id.buy_state_delete)
//                .addOnClickListener(R.id.buy_state_upload);

    }

    public class BuyApplyViewHolder extends BaseViewHolder {

        public BuyApplyViewHolder(View view) {
            super(view);
            AutoUtils.auto(view);
        }
    }
}
